<template>
  <div id="myChart" :style="{width: '800px', height: '600px'}"></div>
</template>

<script>
export default {
  name: "Pie",
  data() {
    return {
      fruits:null
    }
  },
  mounted() {
    let _this = this
    // 基于准备好的dom，初始化echarts实例
    let myChart = this.$echarts.init(document.getElementById('myChart'))
    axios.get("http://localhost:8081/fruit/pie").then(function (response){
      _this.fruits = response.data
      // 绘制图表
      myChart.setOption({
        title: {
          text: '水果销量同级',
          subtext: '饼状图',
          left: 'center'
        },
        tooltip: {
          trigger: 'item'
        },
        legend: {
          orient: 'vertical',
          left: 'left',
        },
        series: [
          {
            name: '访问来源',
            type: 'pie',
            radius: '50%',
            data: _this.fruits,
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)'
              }
            }
          }
        ]
      })
    })


  }
}
</script>

<style scoped>

</style>